package main

import (
	"fmt"
	"sort"
)

func maxIceCream(costs []int, coins int) int {
	size := len(costs)
	sum := 0
	count := 0

	sort.Ints(costs)

	for count = 0; count < size; count++ {
		// fmt.Println(sum, coins, costs[count])
		sum = sum + costs[count]
		if sum > coins {
			break
		}

	}

	return count
}

func () {
	coins := 20
	// costs := []int{1, 3, 2, 4, 1}
	costs := []int{1, 6, 3, 1, 2, 5}
	num := maxIceCream(costs, coins)
	fmt.Println(num)

}
